Skip to content

Don't launch a kernel to permute empty arrays - #798

Merged
maleadt merged 1 commit into
mainfrom
tb/permutedims-empty
Oct 27, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/permutedims-empty

Conversation

@maleadt

@maleadt maleadt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

permutedims! launched its kernel with the destination's size as the ndrange. When a dimension is zero, Metal's KernelAbstractions back-end throws a DivideError for that launch (JuliaGPU/Metal.jl#980), so permutedims of an MtlMatrix with a zero dimension failed. There is nothing to permute, so this returns early; the comment points to the Metal issue.

Tests: permutedims of 0×3 and 4×0×6 arrays (which only fail on Metal).

Found while testing the sparse redesign (#745, stacked above) on Metal; independent of it and fine for 11.x.

@maleadt
maleadt added this pull request to stack #797 September 25, 2026 18:23
@maleadt maleadt added the arrays The array abstraction: broadcasting, mapreduce, indexing, views, generic linear algebra. label Oct 19, 2026
@maleadt
maleadt removed this pull request from stack #797 October 21, 2026 13:00
@maleadt
maleadt added this pull request to stack #832 October 21, 2026 13:00
@maleadt
maleadt force-pushed the tb/sparse-mapreduce branch from 48bb64d to 05b2b7c Compare October 22, 2026 10:46
@maleadt
maleadt force-pushed the tb/permutedims-empty branch from 4705642 to 59e341b Compare October 22, 2026 10:46
@maleadt
maleadt force-pushed the tb/sparse-mapreduce branch from 05b2b7c to f5a2181 Compare October 22, 2026 10:54
@maleadt
maleadt force-pushed the tb/permutedims-empty branch from 59e341b to 4cef05b Compare October 22, 2026 10:54
@maleadt
maleadt marked this pull request as ready for review October 23, 2026 08:11
permutedims! launched its kernel with the destination's size as the
ndrange, which Metal's KernelAbstractions back-end does not support when
it is empty (JuliaGPU/Metal.jl#980): permutedims of an MtlMatrix with a
zero dimension threw a DivideError. There is nothing to permute anyway.
@maleadt
maleadt force-pushed the tb/permutedims-empty branch from 4cef05b to 7776c46 Compare October 23, 2026 08:17
@maleadt
maleadt force-pushed the tb/sparse-mapreduce branch from f5a2181 to 725b64c Compare October 23, 2026 08:17
@maleadt
maleadt removed this pull request from stack #832 October 23, 2026 08:18
@maleadt
maleadt changed the base branch from tb/sparse-mapreduce to main October 23, 2026 08:18
@maleadt
maleadt merged commit 9b3052c into main Oct 27, 2026
18 of 35 checks passed
@maleadt
maleadt deleted the tb/permutedims-empty branch October 27, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays The array abstraction: broadcasting, mapreduce, indexing, views, generic linear algebra.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant